const router = require('../../router');
const orderModel = require('../../../model/order')
const userModel = require('../../../model/user')
const courseModel = require('../../../model/course')

router.get('/learn/account', async (ctx) => {

    const result = await orderModel.findAll({
        where: {status: 1, userId: ctx.session.userLoginId},
        order: [['id', 'DESC']],
        include: [
            {
                model: userModel
            },
            {
                model: courseModel
            },
        ]

    })

    const viewData = Object.assign(ctx.viewData, {
        category: 'course',
        list: result
    });
    ctx.body = await ctx.render('learn/account', viewData)
})